// 获取链接绝对地址
function GetUrl()　　 {　　　　
  var url = document.location.toString();　　　　
  var arrUrl = url.split("//"); 
  var start = arrUrl[1].indexOf("/"); 
  var relUrl = arrUrl[1].substring(start); //stop省略，截取从start开始到结尾的所有字符 
  if (relUrl.indexOf("?") != -1) {
    relUrl = relUrl.split("?")[0];　　　　
  }
  return relUrl;　　
}

function progressBar() {
  var _progressBar = document.createElement("div");
  var doc_BODY = document.body;
  var firstNODE = document.getElementsByTagName('div')[0];
  _progressBar.className = 'progressBar';
  _progressBar.style.cssText += 'background:#ff0000;height:2px;  width: 100%;position:fixed; top:0;z-index:99999;';
  // doc_BODY.insertBefore(_progressBar,firstNODE)
  document.body.appendChild(_progressBar)
}

document.onreadystatechange = function () {
  // console.log(document.readyState); 
  /*  if(document.readyState =="interactive"){  } */
  if (document.readyState == "complete") {
    // $(".progressBar").animate({"width":"100%"},1000)
    $(".progressBar").fadeOut()
    hideLoading()
    $(".works-list-dl-item").animate({
      "opacity": 1
    }, 1500)
  }
}



//加载动画显示
function showLoading() {
  var loading = document.getElementById("weui_loading");
  if (loading) {
    loading.style.display = "block";
  } else {
    var newloading = document.createElement('div');
    newloading.className = "weui_toast";
    newloading.id = "weui_loading";
    newloading.innerHTML = "<div class=\"spinner\"><div class=\"rect1\"><\/div><div class=\"rect2\"><\/div><div class=\"rect3\"><\/div><div class=\"rect4\"><\/div><div class=\"rect5\"><\/div><\/div><p class=\"weui_toast_content\">请稍后…<\/p>";
    document.body.appendChild(newloading);
  }
}
//加载动画隐藏
function hideLoading() {
  var loading = document.getElementById("weui_loading");
  if (loading) {
    loading.style.display = "none";
  }
}

function loading_top() {
  var loading_top_ele = $("<div>")
  loading_top_ele.addClass("loading-top")
  $("body").append(loading_top_ele)
}



function webMask($height, $className, $opacity) {
  var webMask_div = document.createElement("div");
  var _div_style = webMask_div.style;
  webMask_div.className = $className || "webMask";
  _div_style.width = "100%";
  _div_style.height = $height || "100%";
  _div_style.position = "fixed";
  _div_style.left = "0";
  _div_style.bottom = "0";
  _div_style.zIndex = "999";
  _div_style.backgroundColor = "rgba(0, 0, 0, " + ($opacity || 0.8) + ")";
  // _div_style.backgroundColor = "#000000";
  _div_style.opacity = $opacity || "1";
  document.body.appendChild(webMask_div);
  if (document.getElementsByClassName("webMask")[0]) {
    document.getElementsByClassName("webMask")[0].onclick = function () {
      document.body.removeChild(this)
      // this.style.display="none"
    }
    /*  $(".webMask").on("click", function () {
       $(document).unbind('mousewheel');
       $(this).fadeOut(400)
     }) */
  }
}
// webMask("80%","0.4")


// 二维码弹出
$(function () {
  var ewmSrc;
  var ewmImgBox = $("<img>");
  $(".h105 .ewm").on("click", function () {

    webMask();
    ewmSrc = $(this).find("img").attr("src");

    $(".webMask").addClass("dfc").append(ewmImgBox).find("img").attr("src", ewmSrc);
    // console.log(ewmSrc);
    // $(".webMask").toggleClass("webMask")

    // if ($(".webMask")) {
    //   $(".webMask").on("click", function () {
    //     $(this).remove()
    //   })
    // }
  })
})

// $("#swiper-fullScreen").css("height",$("html").height()+"px")
// var swiper_fullScreen_slide = $(".swiper-fullScreen-slide");
// var slidetitle;
// var slideHref;
// var navItem = [];
// var element;
// var element1;
// swiper_fullScreen_slide.each(function (i, ele) {
//   element = swiper_fullScreen_slide.eq(i).attr('data-title')
//   element1 = swiper_fullScreen_slide.eq(i).attr('data-href')
//   navItem.push({
//     "navHref": element1,
//     "title": element
//   })
// });

// $(function(){
//   var swiperfullScreen = new Swiper('#swiper-fullScreen', {
//     direction: 'vertical',
//     swipeHandler: '.swipe-handler',
//     mousewheel: true,
//     spaceBetween: 2,
//     // loop: true, 
//     keyboard: {
//       enabled: true,
//     },
//     lazy: {
//       loadPrevNext: true,
//     },
//     pagination: {
//       el: '.swiper-fullScreen-nav',
//       // clickable: true, 
//       renderBullet: function (index, className) {
//         // 方法一
//         /* slidetitle=swiper_fullScreen_slide.eq(index).attr('data-title')||'';
//         slideHref=swiper_fullScreen_slide.eq(index).attr('data-href')||'';
//         return '<span class="' + className + '">' + '<a href="' + slideHref + '">' + slidetitle +
//         '</a></span>'; */
//         // console.log(slidetitle) 
//       },
//       hideOnClick: true,
//     },
//     on: {
//       init: function () {
//         swiperAnimateCache(this); //隐藏动画元素 
//         swiperAnimate(this); //初始化完成开始动画
//       },
//       slideChangeTransitionEnd: function () {
//         swiperAnimate(this); //每个slide切换结束时也运行当前slide动画
//       }
//     }
//   })
// })

// swiperfullScreen.slideTo(2, 1000, false);
//鼠标滑过pagination控制swiper切换
/* for (i = 0; i < swiperfullScreen.pagination.bullets.length; i++) {
  swiperfullScreen.pagination.bullets[i].index = i
  swiperfullScreen.pagination.bullets[i].onmouseover = function () {
    swiperfullScreen.slideTo(this.index);
  };
} */



//搜索查询
function SiteSearch(send_url, divTgs, channel_name) {
  var strwhere = "";
  if (channel_name !== undefined) {
      strwhere = "&channel_name=" + channel_name
  }
var str = $.trim($(divTgs).val());
if (str.length > 0 && str != "输入关健字") {
    window.location.href = send_url + "?keyword=" + encodeURI($(divTgs).val()) + strwhere;
}
return false;
}
